<template>
  <el-button @click="initRecognize"> 识别 </el-button>
</template>

<script setup>
import { createWorker } from 'tesseract.js'
import { onMounted } from 'vue'
import cnCarImg from '@/assets/re_cn.jpeg'
import CNIMG from '@/assets/CNTEXT.png'

onMounted(() => {})

const initRecognize = async () => {
  const worker = await createWorker('chi_sim')

  const ret = await worker.recognize(CNIMG)

  console.log(ret.data.text)
  await worker.terminate()
  // Tesseract.recognize(CNIMG, "chi_sim", {
  //   logger: (m) => console.log(m),
  // })
  //   .then((result) => {
  //     console.log(result.data.text);
  //   })
  //   .catch((error) => {
  //     console.error(error);
  //   });
}
</script>

<style lang="less" scoped></style>
